home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / sst115j.lzh / SSTWIN.H < prev    next >
C/C++ Source or Header  |  1992-07-17  |  13KB  |  262 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*                                sstwin.h                                  */
  3. /*                                                                          */
  4. /*                           windows header file                            */
  5. /*                                                                          */
  6. /*      CopyRight (C) 1991,1992  Steven Lutrov.   All rights reserved.      */
  7. /* ------------------------------------------------------------------------ */
  8.  
  9. #ifdef    TRUE
  10.      #undef    TRUE
  11. #endif
  12. #ifdef    FALSE
  13.      #undef    FALSE
  14. #endif
  15. #ifdef    ERROR
  16.      #undef    ERROR
  17. #endif
  18. #ifdef    OK
  19.      #undef    OK
  20. #endif
  21.  
  22. #define   TRUE         1
  23. #define   FALSE        0
  24. #define   ERROR        -1
  25. #define   OK           0
  26. #define   ON           1
  27. #define   OFF          0
  28.  
  29. /* ------------------------------------------------------------------------ */
  30. /*                      input field controller structures                   */
  31. /* ------------------------------------------------------------------------ */
  32. typedef struct field {             /* data entry field description */
  33.     char *fmask;               /* field data entry mask        */
  34.     int  fprot;                /* field protection             */
  35.     char *fbuff;               /* field buffer                 */
  36.     int ftype;                 /* field type                   */
  37.     int fflags;                /* field flags                  */
  38.     int frow;                  /* field row                    */
  39.     int fcol;                  /* field column                 */
  40.     void (*fhelp)(char *);     /* field help function          */
  41.     char *fhwin;               /* field help window            */
  42.     int flx, fly;              /* help window location         */
  43.     int helptype;              /* class of help                */
  44.     int (*fvalid)(char *);     /* field post validation func   */
  45.     void (*fprevalid)(int *);  /* field pre validation func    */
  46.     void (*ferror)(char *);     /* field error function         */
  47.         struct field *fnxt;        /* next field on template       */
  48.     struct field *fprv;        /* previous field on template   */
  49. } FIELD;
  50.  
  51.  
  52. /* ------------------------------------------------------------------------ */
  53. /*                        window  controller structures                     */
  54. /* ------------------------------------------------------------------------ */
  55. typedef struct _wnd {
  56.     char *_ws;                /* points to window save block   */
  57.     char *_title;             /* points to window title        */
  58.     char *_footer;            /* points to window footer title */
  59.         int _tjust :8;            /* title justification           */
  60.         int _fjust :8;            /* footer justification          */
  61.         int _wx  :8;              /* nw x coordinate               */
  62.         int _wy  :6;              /* nw y coordinate               */
  63.         int _wv  :1;              /* true if window is visible     */
  64.         int _hd  :1;              /* true if window was hidden     */
  65.         int _ww  :8;              /* window width                  */
  66.         int _wh  :8;              /* window height                 */
  67.         int _wsp :8;              /* scroll pointer                */
  68.         int _sp  :8;              /* selection pointer             */
  69.         int _cr  :8;              /* cursor x location             */
  70.     int btype;                /* border type                   */
  71.         unsigned char wcolour[6]; /* colours for window            */
  72.         unsigned char _pn;        /* previous normal colour        */
  73.     struct _wnd *_nx;         /* points to next window         */
  74.     struct _wnd *_pv;         /* points to previous window     */
  75.     FIELD *_fh;               /* points to 1st data entry fld  */
  76.     FIELD *_ft;               /* points to last data entry fld */
  77. } WINDOW;
  78.  
  79. /* ------------------------------------------------------------------------ */
  80. /*                        window attribute components                       */
  81. /* ------------------------------------------------------------------------ */
  82. #define   WIN_BORDER       0x000           /* border or frame */
  83. #define   WIN_TITLE        0x001           /* title area  */
  84. #define   WIN_ACCENT       0x002           /* accent or highlight bar  */
  85. #define   WIN_FACE         0x003           /* window face */
  86. #define   WIN_FLDFACE      0x004           /* window field face */
  87. #define   WIN_FOOT         0x005           /* window footer */
  88. #define   WIN_ALL          0x006           /* all above components */
  89.  
  90. #define   BRIGHT           0x008           /* high intensity  */
  91. #define   DIM              0x000           /* low intensity  */
  92.  
  93.  
  94. /* ------------------------------------------------------------------------ */
  95. /*                           window border components                       */
  96. /* ------------------------------------------------------------------------ */
  97. #define   BRD_SPACE        0x000           /* single line */
  98. #define   BRD_SINGLE       0x001           /* single line */
  99. #define   BRD_DOUBLE       0x002           /* double line */
  100. #define   BRD_DOUBLESIDE   0x003           /* double sides & single top */
  101. #define   BRD_DOUBLETOP    0x004           /* double top & single sides */
  102. #define   BRD_SINGLESIDE   BRD_DOUBLETOP   /* ditto */
  103. #define   BRD_SINGLETOP    BRD_DOUBLESIDE  /* ditto */
  104.  
  105. #define   BRD_PULLDOWN     0x005           /* used in pulldown menus */
  106. #define   BRD_NOBORDER     0x009           /* no border */
  107.  
  108. /* ------------------------------------------------------------------------ */
  109. /*                         justification components                         */
  110. /* ------------------------------------------------------------------------ */
  111. #define   JUST_C           0x001           /* centre justify */
  112. #define   JUST_L           0x002           /* left justify */
  113. #define   JUST_R           0x004           /* right justify */
  114.  
  115.  
  116. /* ------------------------------------------------------------------------ */
  117. /*                              field components                            */
  118. /* ------------------------------------------------------------------------ */
  119. #define   FIELDCHAR        0x05F           /* "_" char for field masks */
  120.  
  121. #define   FLD_ALNUM        0x001           /* alpha & numeric */
  122. #define   FLD_ALPHA        0x002           /* alpha only */
  123. #define   FLD_DIGIT        0x004           /* digit only */
  124. #define   FLD_ASCII        0x008           /* ascii char only */
  125. #define   FLD_PRINT        0x010           /* printable character */
  126. #define   FLD_XDIGIT       0x020           /* hexadecimal char */
  127. #define   FLD_DATE         0x040           /* date fromat char */
  128. #define   FLD_INT          0x080           /* integer */
  129. #define   FLD_CURR         0x100           /* currency format */
  130.  
  131. /* ------------------------------------------------------------------------ */
  132. /*                          field flag components                           */
  133. /* ------------------------------------------------------------------------ */
  134.  
  135. #define   FLD_LJUST        0x001           /* left justify field */
  136. #define   FLD_RJUST        0x002           /* right justify field */
  137. #define   FLD_TOUPPER      0x004           /* convert field to upper case */
  138. #define   FLD_TOLOWER      0x008           /* convert field to lower case */
  139. #define   FLD_TOPROPER     0x010           /* convert field to Proper case */
  140. #define   FLD_ZFILL        0x020           /* fill blanks with zero char  */
  141.  
  142. /* ------------------------------------------------------------------------ */
  143. /*                          help system components                          */
  144. /* ------------------------------------------------------------------------ */
  145. #define   HELP_KEYED       0x001      /* field help when help key pressed */
  146. #define   HELP_INITIAL     0x002      /* field help when initialy on field */
  147. #define   HELP_ALWAYS      0x002      /* field help when always on field */
  148. #define   HELP_DONE        0x010      /* help completed  */
  149.  
  150.  
  151. /* ------------------------------------------------------------------------ */
  152. /*                          quick access macros                             */
  153. /* ------------------------------------------------------------------------ */
  154. #define SAV              (wnd->_ws)
  155. #define WTITLE           (wnd->_title)
  156. #define WFOOT            (wnd->_footer)
  157. #define TJUST            (wnd->_tjust)
  158. #define FJUST            (wnd->_fjust)
  159. #define COL              (wnd->_wx)
  160. #define ROW              (wnd->_wy)
  161. #define WIDTH            (wnd->_ww)
  162. #define HEIGHT           (wnd->_wh)
  163. #define SCROLL           (wnd->_wsp)
  164. #define SELECT           (wnd->_sp)
  165. #define WCURS            (wnd->_cr)
  166. #define WBORDER          (wnd->wcolour[WIN_BORDER])
  167. #define WTITLEC          (wnd->wcolour[WIN_TITLE])
  168. #define WFOOTC           (wnd->wcolour[WIN_FOOT])
  169. #define WACCENT          (wnd->wcolour[WIN_ACCENT])
  170. #define WFACE            (wnd->wcolour[WIN_FACE])
  171. #define WFIELD           (wnd->wcolour[WIN_FLDFACE])
  172. #define PWIN_FACE        (wnd->_pn)
  173. #define BTYPE            (wnd->btype)
  174. #define NEXT             (wnd->_nx)
  175. #define PREV             (wnd->_pv)
  176. #define WCOLOUR          (wnd->wcolour)
  177. #define VISIBLE          (wnd->_wv)
  178. #define HIDDEN           (wnd->_hd)
  179. #define FHEAD            (wnd->_fh)
  180. #define FTAIL            (wnd->_ft)
  181. #define BORDER_OFFSET    (wnd->btype != BRD_NOBORDER)   /* Added By Richard Deguara */
  182. #define NW               (wcs[wnd->btype].topleft)
  183. #define NE               (wcs[wnd->btype].topright)
  184. #define SE               (wcs[wnd->btype].botright)
  185. #define SW               (wcs[wnd->btype].botleft)
  186. #define SIDE             (wcs[wnd->btype].vert)
  187. #define LINE             (wcs[wnd->btype].hor)
  188.  
  189. /* ------------------------------------------------------------------------ */
  190. /*                      window functions and macros                         */
  191. /* ------------------------------------------------------------------------ */
  192. void    Wclear           (WINDOW *);
  193. void    Wdeleteall       (void);
  194. void    Wcursor          (WINDOW *, int x, int y);
  195. void    Wdelete          (WINDOW *);
  196. void    Wemsg            (char *);
  197. void    Wemsgclear       (void);
  198. WINDOW  *Westablish      (int, int, int, int);
  199. int     Wgetsel          (WINDOW *, int, char *);
  200. void    Whide            (WINDOW *);
  201. void    Wprintf          (WINDOW *, char *, ...);
  202. void    Wprompt          (WINDOW *wnd, int, int, char *);
  203. void    Wputch           (WINDOW *, int);
  204. void    Wputchat         (WINDOW *wnd, int c, int bg, int fg, int i);
  205. void    Wsetborder       (WINDOW *, int);
  206. void    Wsetcolour       (WINDOW *, int, int, int, int);
  207. void    Wsetintensity    (WINDOW *, int);
  208. void    Wsettitle        (WINDOW *, char *, int);
  209. void    Wsetfooter       (WINDOW *, char *, int);
  210. void    Wshow            (WINDOW *);
  211.  
  212. #define Wforefront(wnd)  wndrepos(wnd, 0, 0, 1)
  213. #define Wmove(wnd,x,y)   wndrepos(wnd, COL-x, ROW-y, 0)
  214. #define Wrear(wnd)       wndrepos(wnd, 0, 0, -1)
  215. #define Wresetvideo(wnd) wnd->wcolour[WIN_FACE]=wnd->_pn
  216. #define Wrevvideo(wnd)   wnd->wcolour[WIN_FACE]=wnd->wcolour[WIN_ACCENT]
  217. #define Wrmove(wnd,x,y)  wndrepos(wnd, x, y, 0)
  218.  
  219. /* ------------------------------------------------------------------------ */
  220. /*                         data entry functions                             */
  221. /* ------------------------------------------------------------------------ */
  222. void    Fcleartemplate   (WINDOW *wnd);
  223. int     Fdataentry       (WINDOW *wnd, int p);
  224. int     Fdataview        (WINDOW *wnd);
  225. char   *Finputline       (char *p, char *bf, int x, int y, int l, int t);
  226. void    Ferrorfunc       (FIELD *fld, void (*func)(char *));
  227. void    Fendfunc         (int (*func) (int));
  228. void    Fhelpfunc        (FIELD *fld, void (*func)(char *), int w);
  229. FIELD   *Festablish      (WINDOW *wnd,int,int,char *,char *,int, int);
  230. void    Finittemplate    (WINDOW *wnd);
  231. void    Fnulltemplate    (WINDOW *wnd);
  232. void    Fsethelpwin      (FIELD *fld, char *, int, int);
  233. void    Ftally           (WINDOW *wnd);
  234. void    Fdeleteall       (WINDOW *wnd);
  235. void    DeleteField      (FIELD *fld);
  236.  
  237. #define Fprotect(f,s)       f->fprot=s
  238. #define Fpostvalidate(f,v)  f->fvalid=v
  239. #define Fprevalidate(f,v)   f->fprevalid=v
  240.  
  241. /* ------------------------------------------------------------------------ */
  242. /*                           keyboard functions                             */
  243. /* ------------------------------------------------------------------------ */
  244. unsigned int  kgetch     (void);
  245. int           kkeyhit    (void);
  246. int  far *kstate         (void);
  247.  
  248.  
  249. /* ------------------------------------------------------------------------ */
  250. /*                       internal to window processes                       */
  251. /* ------------------------------------------------------------------------ */
  252. void    accent           (WINDOW *);
  253. void    deaccent         (WINDOW *);
  254. void    scroll           (WINDOW *, int);
  255. void    wndrepos         (WINDOW *, int, int, int);
  256. void    acline           (WINDOW *, int);
  257. void    displ            (WINDOW *wnd, int x, int y, int ch, int at);
  258.  
  259. #define accent(wnd)      acline(wnd, WACCENT)
  260. #define deaccent(wnd)    acline(wnd, WFACE)
  261.  
  262.